package com.event.management.backend.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.event.management.backend.domain.LoginLogs;
import com.event.management.backend.dto.LoginLogQueryDTO;
import com.event.management.backend.service.LoginLogsService;
import com.event.management.backend.util.Result;
import cn.dev33.satoken.annotation.SaCheckRole;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统日志控制器
 */
@Slf4j
@RestController
@RequestMapping("/api/logs")
@Api(tags = "系统日志接口", description = "提供登录日志和操作日志查询功能")
public class LogsController {

    @Autowired
    private LoginLogsService loginLogsService;
    


    /**
     * 查询登录日志列表
     * @param queryDTO 查询参数
     * @return 登录日志列表
     */
    @ApiOperation("查询登录日志列表")
    @SaCheckRole("admin")
    @GetMapping("/login")
    public Result<Page<LoginLogs>> getLoginLogs(LoginLogQueryDTO queryDTO) {
        log.info("查询登录日志列表: pageNum={}, pageSize={}, userId={}, startTime={}, endTime={}", 
                queryDTO.getPageNum(), queryDTO.getPageSize(), queryDTO.getUserId(), 
                queryDTO.getStartTime(), queryDTO.getEndTime());
        
        Page<LoginLogs> page = loginLogsService.getLoginLogPage(queryDTO);
        return Result.success(page);
    }


} 